package utils;

import beans.LogEnum;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;

public class UserLogUtil {
    public static void dbLog(String target, String type, String userId, String message){
        Logger dbLogger = Logger.getLogger("dbLogger");
        MDC.put("target",target);
        MDC.put("type",type);
        MDC.put("userId",userId);
        dbLogger.info(message);
          }

    public static void dbLog(LogEnum target, LogEnum type, String userId, String message){
        dbLog(target.getValue(),type.getValue(),userId,message);
    }

    /**
     * 致命错误日志打印
     * @param message
     */
    public static void consoleLog(String message){
        Logger consoleLogger = Logger.getLogger("consoleLogger");
        consoleLogger.fatal(message);
        consoleLogger.info(message);
    }
    
    /**
     * 控制台打印
     * @param message
     */
    public static void log(String message){
        Logger log = Logger.getLogger("log");
        log.info(message);
    }
}
